﻿using AutoPoco;
using AutoPoco.DataSources;
using AutoPoco.Engine;
using FluentDml.Tests.TestClasses;

namespace FluentDml.Tests
{
    public static class TestData
    {
        public static IGenerationSession GenerateSession<T>()
        {
            IGenerationSessionFactory factory = AutoPocoContainer.Configure(x =>
                        {
                            x.Conventions(c =>
                                            {
                                                c.UseDefaultConventions();
                    
                                            });
                            x.AddFromAssemblyContainingType<T>();
                            x.Include<Person>()
                                .Setup(c => c.FirstName).Use<FirstNameSource>()
                                .Setup(c => c.LastName).Use<LastNameSource>();

                            x.Include<LogEntry>()
                                .Setup(l => l.DateTime).Use<DateOfBirthSource>()
                                .Setup(l => l.Message).Use<LoremIpsumSource>();

                        });

            return factory.CreateSession();
        }
    }
}